home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / XCMDS&XFCNS / PhoneDecode / record.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-12  |  2.5 KB  |  68 lines  |  [TEXT/KAHL]

  1. /* header for the xcmd detecting tones using the microphone */
  2.  
  3. #ifndef __record_h__
  4. #define __record_h__
  5.  
  6. #define kThreshold    127        /* threshold for the raw data */
  7. #define kFFTthreshold 6000    /* threshold for the fft output */
  8.  
  9. #define kExtraMem    0x5000
  10. /* the buffersize must be a power of 2, this is to keep the cost of a division down */
  11. #define kBuffSize    16384    
  12. #define kBuffSizePower    16  /* the power of 2, so 16 gives a buff size = 2^16 */
  13. #define kSampleSize 1        /* 1 byte */
  14. #define kNumsInSample 5        /* a guess of how many individual digits will be in a sample */
  15. #define kSampleDiv2 1024    /* the number of bytes that will go to the fft */
  16. #define kSample 2049        /* 2 times the number of bytes that will go to the fft */
  17. /* structure for a buffer */
  18. typedef struct  {
  19.     Handle    buffer;
  20.     Boolean full;
  21.     long    buffSize;
  22.     short    headerlength;
  23. } BuffInfo;
  24.  
  25. /* structure for the global variable */
  26. typedef struct {
  27.     BuffInfo    *BuffArray;        /* pointer to the array of Sound buffer pointers */
  28.     int             NumBuffers;        /* size of the array */
  29.     int            Error;            /* the callback routines (or other routines) error code */
  30.     SPBPtr        RecordRec;        /* pointer to the currently Recording record */
  31.     Boolean     FullBuffer;        /* True when the RecordRec is full */
  32.     int            RecordingBuff;    /* the number of the buffer in the RecordRec */
  33.     Boolean        PlayAndRecord;  /* machine is capable of both simultaneously? */
  34.     Boolean        Stereo;            /* machine is capable of stereo? */
  35.     Boolean        Quit;            /* are we in the process of quitting? */
  36.     Boolean        FirstTime;        /* is this our first time after initialization? */
  37.     long        SoundRefNum;    /* the reference number of the sound device */
  38.     long double *fftData;        /* the pointer to the array for the data in the fft */
  39. } gGlobalType;
  40.  
  41. /* define error codes */
  42. #define kNoError        -1
  43. #define kNoInput        1
  44. #define kGestaltFailed    2
  45. #define kOpeningDevice    3
  46. #define kGettingRate    4
  47. #define kMemory            5
  48. #define kBufSetup        6
  49. #define kCallbackError    7
  50. #define kStopRecord        8
  51. #define kRecord            9
  52. #define kBuffersFull    10
  53. #define kBadKey            'x'
  54.  
  55. #define TestBit(l,b)    ((l>>b)&0x01)
  56. #define Abs(x)        ((x<0)?-(x):x)
  57.  
  58. /* protypes */
  59. Handle SetUpSounds (Handle Buf, short *HeaderSize, Fixed sampRate);
  60. int findAvailableBuff();
  61. int initToneRecognize();
  62. pascal void myRecordCallback (SPBPtr inParamPtr);
  63. int finishToneRecognize();
  64. long toneRecognize(XCmdPtr paramPtr);
  65. char ParseBuff(BuffInfo buffer,XCmdPtr paramPtr);
  66. void nfft(long double data[],unsigned long nn,int isign);
  67. char findmax(long double data[],unsigned long Samples,XCmdPtr paramPtr);
  68. #endif